import org.apache.commons.io.IOUtils;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

public class writeLines {


    public static void main(String[] args) throws FileNotFoundException, IOException {

        List<String> ls=new ArrayList<>();
        ls.add("asdasd");
        ls.add("ada21");
        ls.add("addsf");
        try(OutputStream os=new FileOutputStream("test4.txt")) {
            IOUtils.writeLines(ls,IOUtils.LINE_SEPARATOR_WINDOWS,os);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
